Topic Connection:problemid=542 "target=" _blank ">zoj 1542 POJ 1861 Network
Network
Time
limit: 2 Seconds
Memory Limit: 65536 KB
Special Judge
andrew is working as system administrator and is planning to establish a new network in he company. There'll is N hubs in the company, they can is connected to each of the other using cables. Since each worker of the company must has access to the whole net
contains, numbers:n-the number of hubs in the network (2 OutputOutput first the maximum length of a cable in your hub connection plan (the value of your should minimize). Then output your Plan:first output p-the number of cables used and then output P pairs of an integer numbers-numbers of hub s connected by the corresponding cable. Separate numbers by spaces and/or line breaks.Sample Input4 61 2 11 3 11 4 22 3 13 4 12 4 1Sample Output141 21 32) 33 4SourceNortheastern Europe 2001, Northern subr
OutputOutput first the maximum length of a cable in your hub connection plan (the value of your should minimize). Then output your Plan:first output p-the number of cables used and then output P pairs of an integer numbers-numbers of hub s connected by the corresponding cable. Separate numbers by spaces and/or line breaks.Sample Input4 61 2 11 3 11 4 22 3 13 4 12 4 1Sample Output141 21 32) 33 4SourceNortheastern Europe 2001, Northern subregionTest instructionsThere are n vertices, m-bars, each
is minimal. There is another problem-not each hub can being connected to any other one because of compatibility problems and building g Eometry limitations. Of course, Andrew would provide you all necessary information about possible hub connections. EW to find the the-the-connect hubs so, all above conditions is satisfied. InputThe first line of the input contains double integer NUMBERS:N-the number of hubs in the network (2 always is at least one and connect all hubs.OutputOutput First the
OutputOutput first the maximum length of a cable in your hub connection plan (the value of your should minimize). Then output your Plan:first output p-the number of cables used and then output P pairs of an integer numbers-numbers of hub s connected by the corresponding cable. Separate numbers by spaces and/or line breaks.Sample Input4 61 2 11 3 11 4 22 3 13 4 12 4 1Sample Output141 21 32) 33 4SourceNortheastern Europe 2001, Northern subregionPs:It seems that the case of the problem is a bit pr
contains, numbers:n-the number of hubs in the network (2 OutputOutput first the maximum length of a cable in your hub connection plan (the value of your should minimize). Then output your Plan:first output p-the number of cables used and then output P pairs of an integer numbers-numbers of hub s connected by the corresponding cable. Separate numbers by spaces and/or line breaks.Sample Input4 61 2 11 3 11 4 22 3 13 4 12 4 1Sample Output141 21 32) 33 4Title Analysis: The original topic of Peking
POJ 1861 Network (Kruskal for MST template)
Network
Time Limit:1000 MS
Memory Limit:30000 K
Total Submissions:14103
Accepted:5528
Special Judge
DescriptionAndrew is working as system administrator and is planning to establish a new network in his company. there will be N hubs in the company, they can be connected to each other using cables. since each worker of the company must have access to the whole net
Topic Connection: ZOJ 1542 POJ 1861 Network
Network
Time
limit: 2 Seconds
Memory Limit: 65536 KB
Special Judge
andrew is working as system administrator and is planning to establish a new network in he company. There'll is N hubs in the company, they can is connected to each of the other using cables. Since each worker of the company must has access to the whole network, each hub must is accessibl
Topic Links:1861Test instructionsand M-point n edges to make up two endpoints of the maximum and all sides of the smallest spanning treeBare minimum spanning tree plus two optimizations1. Path compression: When looking for the X element's root node D, all the father nodes of X are directly transformed into the child nodes of the root nodeTo reduce the lookup time of the next lookup2. Consider two nodes in the process of and check the number of child nodes, and less as child nodesCode:POJ
{ - intAa=find (a), bb=find (b); $ inttemp=fa[aa]+FA[BB]; the if(FA[AA]GT;FA[BB])//Merge by Rank the { thefa[aa]=BB; thefa[bb]=temp; - } in Else{ thefa[bb]=AA; thefa[aa]=temp; About } the } the intCompConst void*a,Const void*b) the { +EDGE aa=* (ConstEDGE *) A; -EDGE bb=* (ConstEDGE *) b; the returnaa.value-Bb.value;Bayi } the intCMP (EDGE A,edge B) the { - returna.valueB.value; - } theInlinevoidKruskal () the { theCnt=0; the intu,v; - init (); the f
Title Link: http://poj.org/problem?id=1861Very similar to the previous topic, more interesting is a bit deceptive here, but I did not notice, Fluke. Fortunately, the sample did not look closely. The topic is only required to find the longest edge in the case of ensuring that all vertices are linked. The total weight of the path is not required to be minimal. So you can add any additional edges that are less than the longest edge weight, although he may be a ring. All have a wonderful sample. In
Output
Output first the maximum length of a single cable in your Hub Connection plan (the value you should minimize ). then output your plan: first output p-the number of cables used, then output p pairs of integer numbers-numbers of hubs connected by the corresponding cable. separate numbers by spaces and/or line breaks.
Sample Input
4 6
1 2 1
1 3 1
1 4 2
2 3 1
3 4 1
2 4 1
Sample output
1
4
1 2
1 3
2 3
3 4
Source
Northeastern Europe 2001, northern subregion
/****************************
Question address: http://acm.hdu.edu.cn/showproblem.php? PID = 1861 one postgraduate entrance exam computer question = B
Train of Thought: place the information in the struct, then exist in the vector, and finally scan to n = 0 for statistics, output, and clear the vector.
It should be noted that a single ship may be rented twice, so when scanning op = 'E', it should be handled immediately.
2. When op = 'E' is scanned, check whether there is a s recor
ship number 1 is read, all inputs are completed and the corresponding results are not output.Output:Output 1 rows For each test case, that is, the number of visitors to the day and the average chartering time (in minutes, an integer time in units of digits).Code:intmp[ the];intboat[ the];intMain () {intCountt =0; intTimetot =0; intS,hour,minute; Charkind; MEM (MP,0); while(SCANF ("%d", s), s!=-1) {GetChar (); scanf ("%c",kind); scanf ("%d:%d",hour,minute); intTiming = hour* -+minute; if(s==0){
Test instructions: Solves the minimum spanning tree, and the bottleneck edge on the minimum bottleneck spanning tree.Idea: Just ask for the minimum spanning tree. The bottleneck edge is the one with the largest weight on the spanning tree.1 //#include 2#include 3#include 4#include 5#include 6 #defineINF 0x7f7f7f7f7 #definePII pair8 #defineLL Long Long9 using namespacestd;Ten Const intn=16100; One A intSeq[n], a[n], b[n], w[n], pre[n]; - intcmpintAintb) - { the returnw[a]W[b]; - } - - intFi
contains, numbers:n-the number of hubs in the network (2 OutputOutput first the maximum length of a cable in your hub connection plan (the value of your should minimize). Then output your Plan:first output p-the number of cables used and then output P pairs of an integer numbers-numbers of hub s connected by the corresponding cable. Separate numbers by spaces and/or line breaks.Sample Input4 61 2 11 3 11 4 22 3 13 4 12 4 1Sample Output141 21 32) 33 4SourceNortheastern Europe 2001, Northern subr
Http://www.lydsy.com/JudgeOnline/problem.php? Id = 1861
After the three key functions are written, the simulation questions of water and water are used to rotate them. So easy
Note the following points:
1: Fetch a node in the splay and insert it back. Remember to clear the Left and Right sons of the node.
2: Do not forget to make up after each change.
No ..
# Include
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.